package com.wsx.ones.boots.exception;

import com.wsx.ones.api.OnesResponse;
import com.wsx.ones.exception.OnesException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author wangshuaixin
 * @Title: com.wsx.ones.boots.exception.GlobalExceptionHandler
 * @Description: TODO
 * @date 2019/04/19
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);


    @ExceptionHandler(OnesException.class)
    public OnesResponse handleOnesException(OnesException e) {
        logger.error("ones controller error", e);
        return new OnesResponse();
    }

    @ExceptionHandler(Exception.class)
    public OnesResponse handleException(Exception e) {
        logger.error("controller error", e);
        return new OnesResponse();
    }
}
